#pragma once

#include <iostream>
#include <string>
#include <vector>

namespace micromq
{
    class StringHelper
    {
    public:
        // news.music.pop
        // news..music.pop
        static std::vector<std::string> split(const std::string& str, const std::string& sep)
        {
            int pos = 0;
            int index = 0;
            std::vector<std::string> result;
            while(index < str.size())
            {
                pos = str.find(sep, index);
                if(pos == std::string::npos)
                {
                    result.push_back(str.substr(index));
                    break;
                }
                if(pos != index) 
                {
                    result.push_back(str.substr(index, pos-index));
                }
                index = pos + sep.size();
            }
            return result;
        }
    };
}